package znyl.nursing.controller.member;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import znyl.common.core.controller.BaseController;
import znyl.common.core.domain.R;
import znyl.common.core.page.TableDataInfo;
import znyl.nursing.domain.NursingProject;
import znyl.nursing.dto.OrersDTO;
import znyl.nursing.service.INursingProjectService;

import java.util.List;

@Api(tags = "小程序端护理项目管理")
@RestController
@RequestMapping("/member/orders")
public class MemberOrersController extends BaseController {
    @Autowired
    private INursingProjectService projectOrderService;
    /**
     * 分页查询护理项目列表
     * @return
     */
    /**
     * 查询护理项目列表
     */
//    http://localhost:8081/member/orders/project/page?pageNum=1&pageSize=10&name=%E4%BF%AE&page=1
    @GetMapping("/project/page")
    @ApiOperation("查询护理项目列表")
    public TableDataInfo list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                              @RequestParam(value = "name", defaultValue = "", required = false) String name,
                              @RequestParam(value = "page", defaultValue = "1", required = false) Integer page
                              )
    {
        IPage<NursingProject> page1 =new Page<>(pageNum,pageSize);
        TableDataInfo list =projectOrderService.Ipage(page1,name,page);
        return  list;
    }
    /**
     * 查询护理项目列表
     */
    @GetMapping("project/{id}")
    @ApiOperation("查询护理项目列表")
    public R<NursingProject> list(@PathVariable("id") Long id)
        {
        NursingProject nursingProject =projectOrderService.getById(id);
        return  R.ok(nursingProject);
    }
}
